Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ImageMagick command for v7 option handling #254

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

tagliala
Copy link
Member

Options specified before the input image can be interpreted as options to generate an image.

Example:

convert -size 300x200 xc:lightblue image.png

The -size and xc:lightblue options create a new image, and image.png is considered the output file.

By moving the options after the input image, we ensure that the input file is interpreted correctly and only the output is modified according to the specified options.

This will also add compatibility to ImageMagick v7

Options specified before the input image can be interpreted as options
to generate an image.

Example:

```
convert -size 300x200 xc:lightblue image.png
```

The `-size` and `xc:lightblue` options create a new image, and
`image.png` is considered the output file. 

By moving the options **after** the input image, we ensure that the
input file is interpreted correctly and only the output is modified
according to the specified options.

This will also add compatibility to ImageMagick v7
@tagliala
Copy link
Member Author

tagliala commented Sep 12, 2024

Tested locally with ImageMagick v7 and v6

md5 checksums are the same:

$ convert --version
Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP(3.1) 
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc heic jbig jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zlib

$ convert -depth 8 -density 300 -background white -alpha off png-demo.png png-demo.tiff && md5sum png-demo.tiff
9b7a1a8a173c5519bb6aa7f6cfeb9481  png-demo.tiff

$ convert png-demo.png -depth 8 -density 300 -background white -alpha off png-demo.tiff && md5sum png-demo.tiff
9b7a1a8a173c5519bb6aa7f6cfeb9481  png-demo.tiff
$ magick --version
Version: ImageMagick 7.1.1-38 Q16-HDRI x86_64 22398 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(5.0) 
Delegates (built-in): bzlib fontconfig freetype gslib heic jng jp2 jpeg jxl lcms lqr ltdl lzma openexr png ps raw tiff webp xml zlib zstd
Compiler: gcc (4.2)

$ magick png-demo.png -depth 8 -density 300 -background white -alpha off png-demo.tiff && md5sum png-demo.tiff
2ab0d2a5e344a24be573d368c5f15e0d  png-demo.tiff

$ magick -depth 8 -density 300 -background white -alpha off png-demo.tiff && md5sum png-demo.png png-demo.tiff
magick: no images found for operation `-alpha' at CLI arg 7 @ error/operation.c/CLIOption/5481.

@tagliala tagliala merged commit 4b070c7 into master Sep 12, 2024
1 check passed
@tagliala tagliala deleted the feature/improve-convert-command branch September 12, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant